import { createRouter, createWebHashHistory } from "vue-router";

import TopLayoutVue from "@/layout/TopLayout.vue";
import IFrameViewVue from '@/layout/IFrameView.vue';

import HomeVue from "@/views/Home.vue";
import ForgetPasswordVue from "@/views/ForgetPassword.vue";
import LoginVue from "@/views/Login.vue";
import RegisterVue from "@/views/Register.vue";

import ProfileVue from "@/views/personal-center/Profile.vue";
import ChangePasswordVue from "@/views/personal-center/ChangePassword.vue";
import MessageCenterVue from "@/views/message-center/MessageCenter.vue";

const IFRAME_VIEW_ROUTE_PATH = "/iframe";

const routes = [
  {
    path: "/",
    redirect: "/layout",
  },
  {
    path: "/layout",
    name: "Layout",
    component: TopLayoutVue,
    redirect: "/home",
    children: [
      {
        path: "/home",
        name: "Home",
        component: HomeVue,
      },
      {
        path: "/profile",
        name: "Profile",
        component: ProfileVue,
      },
      {
        path: "/change-password",
        name: "ChangePassword",
        component: ChangePasswordVue,
      },
      {
        path: "/message-center",
        name: "MessageCenter",
        component: MessageCenterVue,
      },
      {
        path: IFRAME_VIEW_ROUTE_PATH,
        component: IFrameViewVue,
      },
    ]
  },
  {
    path: "/login",
    name: "Login",
    component: LoginVue,
  },
  {
    path: "/register",
    name: "Register",
    component: RegisterVue,
  },
  {
    path: "/forget-password",
    name: "ForgetPassword",
    component: ForgetPasswordVue,
  },
];

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: routes,
});

export default router;
